package com.ssm.auth.infra.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.ssm.auth.infra.basic.entity.AuthPermission;
import com.ssm.auth.infra.basic.mapper.AuthPermissionDao;
import com.ssm.auth.infra.basic.service.AuthPermissionService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AuthPermission)表服务实现类
 *
 * @author makejava
 * @since 2024-12-13 10:07:40
 */
@Service("authPermissionService")
@Log4j2
public class AuthPermissionServiceImpl implements AuthPermissionService {
    @Resource
    private AuthPermissionDao authPermissionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AuthPermission queryById(Long id) {
        return this.authPermissionDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param authPermission 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(AuthPermission authPermission) {
        if(log.isInfoEnabled()) {
            log.info("AuthPermissionService.add.authPermission:{}", JSON.toJSONString(authPermission));
        }
        return this.authPermissionDao.insert(authPermission);
    }

    /**
     * 修改数据
     *
     * @param authPermission 实例对象
     * @return 实例对象
     */
    @Override
    public int update(AuthPermission authPermission) {
        if(log.isInfoEnabled()) {
            log.info("AuthPermissionService.update.authPermission:{}", JSON.toJSONString(authPermission));
        }
        return this.authPermissionDao.update(authPermission);
    }

    /**
     * 根据id批量查询
     * @param permissionIds
     * @return
     */
    @Override
    public List<AuthPermission> queryByPermissionList(List<Long> permissionIds) {
        List<AuthPermission> authPermissions = authPermissionDao.queryByPermissionList(permissionIds);
        if(log.isInfoEnabled()) {
            log.info("AuthPermissionService.queryByPermissionList.authPermissions:{}", JSON.toJSONString(authPermissions));
        }
        return authPermissions;
    }

}
